//
//  MakeSucessView.m
//  Demo
//
//  Created by MacPro on 15/12/9.
//  Copyright © 2015年 pccb. All rights reserved.
//

#import "MakeSucessView.h"

@interface MakeSucessView ()

@property (strong, nonatomic) UILabel *titleLabel;

@end

@implementation MakeSucessView

- (instancetype)initMakeSucessViewWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        
        UIView *containerView = [[UIView alloc] init];
        containerView.backgroundColor = [UIColor whiteColor];
        containerView.frame = CGRectMake(0, 0, 280.0f, 160.0f);
        containerView.layer.borderWidth = 0.5f;
        containerView.layer.borderColor = [UIColor blackColor].CGColor;
        [self addSubview:containerView];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 20.0f, containerView.width, 30.0f)];
        self.titleLabel.text = @"您已预约成功";
        self.titleLabel.font = Default_Font_16;
        self.titleLabel.backgroundColor = [UIColor clearColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [containerView addSubview:self.titleLabel];
        
        //关闭
        UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        closeBtn.frame = CGRectMake(containerView.width - 37.0f, 0.0f, 34.0f, 34.0f);
        closeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [closeBtn setTitle:@"X" forState:UIControlStateNormal];
        [closeBtn setTitleColor:HexRGB(0x7d7d7d) forState:UIControlStateNormal];
        [closeBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
        closeBtn.titleLabel.font = Default_Font_16;
        closeBtn.backgroundColor = [UIColor clearColor];
        [closeBtn addTarget:self action:@selector(clickCloseBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:closeBtn];
        
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, self.titleLabel.bottom, containerView.width/2.0f, 30.0f)];
        label.text = @"有问题请咨询";
        label.font = Default_Font_14;
        label.textAlignment = NSTextAlignmentRight;
        [containerView addSubview:label];
        
        UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(containerView.width/2.0f + 1.0f, self.titleLabel.bottom, containerView.width/2.0f - 1.0f, 30.0f)];
        label2.text = @"400-123-123";
        label2.font = Default_Font_14;
        label2.textColor = DefaultColor_NavigationBar;
        label2.textAlignment = NSTextAlignmentLeft;
        [containerView addSubview:label2];
        
        UIImageView *successImageView = [[UIImageView alloc] initWithFrame:CGRectMake((containerView.width - 50.0f)/2.0f, label.bottom + 10.0f, 50, 50)];
        NSString *path = [[NSBundle mainBundle] pathForResource:@"Visit_success" ofType:@"png"];
        successImageView.image = [UIImage imageWithContentsOfFile:path];
        [containerView addSubview:successImageView];
        
        containerView.layer.shadowColor = [UIColor blackColor].CGColor;
        containerView.layer.shadowOffset = CGSizeMake(0, 0);
        containerView.layer.shadowOpacity = 0.7;
    }
    
    return self;
}

- (void)clickCloseBtnAction:(UIButton *)sender
{
    [self removeFromSuperview];
}

@end
